#include "PersonTable.h"

PersonTable::PersonTable() {

}

PersonTable::~PersonTable() {

}

void PersonTable::addRow(const Person& row) {
	rows.push_back(row);
}

vector<Person> PersonTable::getAllRows() const {
	return rows;
}

vector<Person> PersonTable::getByName(Person& person) {
	vector<Person> result;
	for (vector<Person>::iterator it = rows.begin(); it != rows.end(); ++it) {
		if (person.compareByName(*it))
			result.push_back(*it);
	}
	return result;
}

vector<Person> PersonTable::getByAddress(Person& person) {
	vector<Person> result;
	for (vector<Person>::iterator it = rows.begin(); it != rows.end(); ++it) {
		if (person.compareByAddress(*it))
			result.push_back(*it);
	}
	return result;
}
vector<Person> PersonTable::getByPhone(Person& person) {
	vector<Person> result;
	for (vector<Person>::iterator it = rows.begin(); it != rows.end(); ++it) {
		if (person.compareByPhone(*it))
			result.push_back(*it);
	}
	return result;
}

vector<Person> PersonTable::getByAll(Person& person) {
	vector<Person> result;
	for (vector<Person>::iterator it = rows.begin(); it != rows.end(); ++it) {
		if (person.compareByAll(*it))
			result.push_back(*it);
	}
	return result;
}
void PersonTable::print() {
	for (vector<Person>::iterator it = rows.begin(); it != rows.end(); ++it) {
		cout << "Nombre: " << it->name << " Dir: " << it->address << " Tel: "
				<< it->phone << endl;
	}

}
